package cn.zane.designPattern.createPatterns.abstractFactoryPatterns.design.workshop.impl;

import cn.zane.designPattern.createPatterns.abstractFactoryPatterns.design.workshop.ICacheAdapter;
import cn.zane.designPattern.createPatterns.abstractFactoryPatterns.oldCode.redis.cluster.IIR;

import java.util.concurrent.TimeUnit;

/**
 * @Author: zane
 * @Date: 2024/12/29
 * @Description:
 */
public class IIRCacheAdapter implements ICacheAdapter {

    private final IIR iir = new IIR();

    @Override
    public String get(String key) {
        return iir.get(key);
    }

    @Override
    public void set(String key, String value) {
        iir.set(key, value);
    }

    @Override
    public void set(String key, String value, long timeout, TimeUnit unit) {
        // 这里就体现了适配器的作用。egm是setEx;iir是setExpire
        iir.setExpire(key, value, timeout, unit);
    }

    @Override
    public void del(String key) {
        iir.del(key);
    }
}
